//
//  HJDKnowTableViewCell.m
//  常州红房子
//
//  Created by 胡金东 on 16/7/23.
//  Copyright © 2016年 胡金东. All rights reserved.
//

#import "HJDKnowTableViewCell.h"

@implementation HJDKnowTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.sourceK = [[UILabel alloc]initWithFrame:CGRectZero];
        self.sourceK.font = [UIFont systemFontOfSize:12];
        self.sourceK.textColor = [UIColor getColorWithHexNumber:@"BDBDBD"];
        [self addSubview:self.sourceK];
        
        self.nameK = [[UILabel alloc]initWithFrame:CGRectZero];
        self.nameK.font = [UIFont systemFontOfSize:19];
        self.nameK.textColor = [UIColor getColorWithHexNumber:@"323232"];
        self.nameK.numberOfLines = 2;
        [self addSubview:self.nameK];
        
        self.sumBackView = [[UILabel alloc]initWithFrame:CGRectZero];
        self.sumBackView.backgroundColor = [UIColor getColorWithHexNumber:@"5AC7AB"];
        [self.sumBackView setRadius:4 borderWith:0 borderColor:nil];
        [self addSubview:self.sumBackView];
        
        self.sum = [[UILabel alloc]initWithFrame:CGRectZero];
        self.sum.font = [UIFont systemFontOfSize:10];
        self.sum.textColor = [UIColor getColorWithHexNumber:@"FFFFFF"];
        self.sum.textAlignment = NSTextAlignmentCenter;
        [self.sumBackView addSubview:self.sum];
        
        self.content = [[UILabel alloc]initWithFrame:CGRectZero];
        self.content.font = [UIFont systemFontOfSize:15];
        self.content.textColor = [UIColor getColorWithHexNumber:@"848484"];
        self.content.numberOfLines = 2;
        [self addSubview:self.content];
        
        self.hengView = [[UIView alloc]initWithFrame:CGRectZero];
        self.hengView.backgroundColor = [UIColor getColorWithHexNumber:@"D6D6D6"];
        [self addSubview:self.hengView];
        
    }
    return self;
}

-(void)layoutSubviews{
    
    CGFloat sourceX = 13;
    CGFloat sourceY = 20;
    CGFloat sourceW = HJDWidth - 26;
    CGFloat sourceH = 25;
    self.sourceK.frame = CGRectMake(sourceX, sourceY, sourceW, sourceH);
    
    CGFloat nameKX = 13;
    CGFloat nameKY = CGRectGetMaxY(self.sourceK.frame)+15;
    CGFloat nameKW = HJDWidth - 26;
    CGRect nameKRect = [_nameK.text boundingRectWithSize:CGSizeMake(nameKW, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObjectsAndKeys:self.nameK.font,NSFontAttributeName, nil] context:nil];
    self.nameK.frame = (CGRect){{nameKX,nameKY},nameKRect.size};

    CGFloat sumBackX = 13;
    CGFloat sumBackY = CGRectGetMaxY(self.nameK.frame)+10;
    CGFloat sumBackW = 50;
    CGFloat sumBackH = 25;
    self.sumBackView.frame = CGRectMake(sumBackX, sumBackY, sumBackW, sumBackH);
    
    CGFloat sumX = 0;
    CGFloat sumY = 2;
    CGFloat sumW = 50;
    CGFloat sumH = 20;
    self.sum.frame = CGRectMake(sumX, sumY, sumW, sumH);
    
    CGFloat contentX = CGRectGetMaxX(self.sumBackView.frame)+5;
    CGFloat contentY = CGRectGetMaxY(self.nameK.frame)+9;
    CGFloat contentW = HJDWidth - 50 -26;
    CGFloat contentH = 36;
    self.content.frame = CGRectMake(contentX, contentY, contentW, contentH);
//    CGRect contentRect = [_content.text boundingRectWithSize:CGSizeMake(contentW, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObjectsAndKeys:self.content.font,NSFontAttributeName, nil] context:nil];
//    self.content.frame = (CGRect){{contentX,contentY},contentRect.size};
//    
//    NSLog(@"%f",contentRect.size.height);
    
    CGFloat hengViewX = 13;
    CGFloat hengViewY = CGRectGetMaxY(self.content.frame)+20;
    CGFloat hengViewW = HJDWidth-26;
    CGFloat hengViewH = 1;
    self.hengView.frame = CGRectMake(hengViewX,hengViewY, hengViewW, hengViewH);
    
}






- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
